﻿ 
@model  ListenMusic.Playlist_ServiceReference.Playlist
@{
    ViewBag.Title = "EditPlaylist";
    Layout = "~/Views/Shared/_LayoutPublic.cshtml";
    List<ListenMusic.Playlist_ServiceReference.FavoritePlayList> lstplaylist = ViewBag.Playlist_Detail;
}
<script src="../../Scripts/Confirm%20popup/jquery_facebook.alert.js" type="text/javascript"></script>
<link href="../../Styles/Confirm%20Popup/facebook.alert.css" rel="stylesheet" type="text/css" />
<link href="../../Styles/Playlist/UserPlaylist.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(document).ready(function () {
        $("#goaction").click(function () {
            if( $("#pln").val() == "")
            {
               $("#error").html("<h2>Không Được Để Trống Tên Playlist</h2>");
            }
            else
            {
                  var param = {
                 pln : $("#pln").val() ,
                 file: $("#file").val() , 
                  op:  $('input[name=op]:checked').val(), 
                 plid: $("#plid").val(),
             };
              $.post("/Info/ProcessEditPlaylist",param,function(data){
                  $("#result").html("<h2>"+data+"</h2>");
              });
          }
        });
         $(".remove").click(function (event) {
             var lstid = jQuery(this).attr("id");
             var str = lstid.split("-");
              var param={fid:str[0]};
               jConfirm('Xác Nhận Xoá Bài Hát Này?', 'Xác Nhận',
			    function(r) {
			    if(r==true)
			    {              
                    $.post("/Info/RemoveSong",param,function(data){
                    if(data == true)
                    {
                        $("#box-"+str[1]).fadeOut(300);
                    }         
                 });     
			    }
			});

        });
        $("a[id=editpicture]").click(function(){
                 var da = $('div #contentedit');
                 if(da.css('display') == 'none')
                 {
                        da.css({'display' : 'block'});
                 }
                 else
                 {
                        da.css({'display' : 'none'});
                 }
         });
           $("a[id=closecontent]").click(function(){
                 var da = $('div #contentedit');
                 
                        da.css({'display' : 'none'});
                 
         });
    });
</script>
<form action="/info/EditPlaylistPicture" id="editplfrm" enctype="multipart/form-data" method="post">
@Html.Hidden("plid",@Model.PlaylistID)
 <div id="edit-playlist" >
       <div id="edit-content" >			
           <fieldset id="pageHeader" class="regHeader" >           
                <legend><h3>Cập nhật Playlist</h3></legend> 
                 <table>
                    <tr>
                        <td colspan="3" align="center"><div id="result" style="font-family:Tahoma" ></div></td>
                    </tr>
                    <tr>
                        <td>Tên Playlist: </td>
                        <td><input type="text" name="pln" id="pln" value="@Model.PlaylistName" maxlength="100" /></td><td><div id="error" style="color:Red"></div></td>
                    </tr>
                    <tr>
                        <td>Tuỳ Chọn:</td>
                        <td>
                            @if(Model._Status == true)
                            {
                                <input type="radio" name="op" value="true" checked="checked" /> @:Cá Nhân
                                <input type="radio" name="op" value="false" /> @:Chia Sẽ
                             }
                             else
                             {
                                  <input type="radio" name="op" value="true"  /> @:Cá Nhân
                                   <input type="radio" name="op" value="false" checked="checked" />@:Chia Sẽ
                             }
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Hình Playlist:
                        </td>
                        <td>
                           <img src="../../Images/Playlist/@Model.Picture" alt="" width="100px" height="100px"/><br />
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><a href="#" id="editpicture">Thay Đổi Hình</a>
                            <div id="contentedit" style="display:none"> 
                                <input type="file"  name="file"/> <br />
                                <input type="button" onclick="submitform('editplfrm')" value="Lưu" /> Hoặc  <a href="#" id="closecontent">Huỷ Bỏ</a>                                 
                            </div>
                        </td>
                    </tr>
                </table>
                <hr />
                <h4>Các bài hát trong playlist: </h4>
                <br />
                <div class="item-song">      
                @{int j = 0;} 
             @foreach (ListenMusic.Playlist_ServiceReference.FavoritePlayList p in lstplaylist)
              {
                  j++;                	
                    <div id="box-@p.SongID">
                        <table width="100%">
                            <tr>
                                <td><a href="" class="sname">@j.@p.SongName </a></td>                                        
                                <td style="text-align:right;"> <a href="#" class="remove" id="@p.FavoritesID-@p.SongID" >
                                <img src="../../Images/delete.png" width="20" height="20" alt="Xóa" /></a> </td>
                            </tr>
                        </table>
                        </div>                                   
			        	       
              }
                </div>      
              <br />
                 <div class="btnsave"><input type="button" id="goaction"  value="Lưu Lại" /></div>
              </fieldset>  
            </div>
 </div>
</form>
          
    
